package lbj.cyw.dp;

/*
* 121. 买卖股票的最佳时机
* */
public class MaxProfit121 {
    public int maxProfit(int[] prices) {
        int n= prices.length;
        int[] dp=new int[n];
        int a =0;
        int min=prices[0];
        for (int i = 1; i < n; i++) {
            a=Math.max(a,prices[i]-min);
            min=Math.min(min,prices[i]);
        }
        return a;
    }

}
